<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <title>add</title>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBygx3oVSEUehAD3YZhNuEUngTDsSfDHRc&amp;sensor=false"></script>
    </h:head>
    <h:body>

        <h:form prependId="false" id="main"  >  
            <p:growl id="growl" showDetail="true" sticky="false" life="6000"  />  
             <p:dialog widgetVar="dlg" showEffect="fade">
                            <h:panelGrid columns="2">
                                <f:facet name="header">
                                    <p:outputLabel value="New Point"/>
                                </f:facet>
                                <h:outputLabel for="title" value="Title:" />
                                <p:inputText id="title" value="#{tranServiceBeanWizerd.title}" />
                                <p:outputLabel for="console" value="Type: " />
                                <p:selectOneRadio id="console" value="#{tranServiceBeanWizerd.type}">
                                    <f:selectItem itemLabel="Terminal" itemValue="Terminal" />
                                    <f:selectItem itemLabel="Stop" itemValue="Stop" />
                                    <f:selectItem itemLabel="Point" itemValue="Point" />
                                </p:selectOneRadio>
                                <f:facet name="footer">
                                    <p:commandButton value="Add" actionListener="#{tranServiceBeanWizerd.newPoint()}" update=":main:map,:main:maph" oncomplete="markerAddComplete()" />
                                    <p:commandButton value="Cancel" onclick="return cancel()" />
                                </f:facet>
                            </h:panelGrid>
                            <h:inputHidden id="Nlat" value="#{tranServiceBeanWizerd.lat}"  />
                            <h:inputHidden id="Nlng" value="#{tranServiceBeanWizerd.lng}" />
                        </p:dialog>
            <h:inputHidden id="t1lat" value="#{tranServiceBeanWizerd.t1Lat}"  />
                        <h:inputHidden id="t1lng" value="#{tranServiceBeanWizerd.t1Lng}" />
                        <h:inputHidden id="t2lat" value="#{tranServiceBeanWizerd.t2Lat}" />
                        <h:inputHidden id="t2lng" value="#{tranServiceBeanWizerd.t2Lng}" />
                        <h:inputHidden id="waypoint" value="#{tranServiceBeanWizerd.request}" />  
                        <h:inputHidden id="waypointh" value="#{tranServiceBeanWizerd.requesth}" />  
            <p:wizard flowListener="#{tranServiceBeanWizerd.onFlowProcess}"  >  
                <p:tab id="ts" title="Transportation Service">  
                    <p:panel header="Transportation Service Details">  
                        <h:messages errorClass="error"/>  
                        <h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">  
                            <h:outputText value="Name: *" />  
                            <p:inputText required="true" requiredMessage="Please enter Transportation Service Name!" label="Name"  
                                         value="#{tranServiceBeanWizerd.tranService.name}" />  

                            <!--TST-->
                            <p:selectOneMenu required="true" requiredMessage="Please select Transportation Type!" id="city" value="#{tranServiceBeanWizerd.tstid}">
                                <f:selectItem  itemLabel="Select Transportation Type" itemValue=""  />
                                <f:selectItems  value="#{tranServiceBeanWizerd.tST}" />
                                <p:ajax  update="suburbs" 
                                         listener="#{tranServiceBeanWizerd.handleTSTChange()}" />
                                <p:ajax  update="newatt:att,newatt" 
                                         />
                            </p:selectOneMenu>

                            <h:outputText value="Default Attributes" /> 
                            <br/>
                            <p:dataTable  id="suburbs" value="#{tranServiceBeanWizerd.tSTAttributeTypes}" var="at">  


                                <p:column>  
                                    <f:facet name="header">  
                                        <h:outputText value="name" />  
                                    </f:facet>  
                                    <h:outputText value="#{at.attributeType.name}"/> 

                                </p:column>  
                                <p:column>  
                                    <f:facet name="header">  
                                        <h:outputText value="value" />  
                                    </f:facet>  
                                    <h:outputText value="#{at.value}" />  

                                </p:column>  
                            </p:dataTable>  


                            <br/>

                            <p:dataTable emptyMessage="Add Attributes" id="newatt" value="#{tranServiceBeanWizerd.tranServiceAttributesDataModel}" var="tsa">  
                                <p:column>  
                                    <f:facet name="header">  
                                        <h:outputText value="name" />  
                                    </f:facet>  
                                    <h:outputText value="#{tsa.tranServiceTypeAttributeType.attributeType.name}" /> 
                                    <f:facet name="footer">  
                                        <p:selectOneMenu required="false"   id="att" value="#{tranServiceBeanWizerd.atid}">
                                            <f:selectItem noSelectionOption="true" itemLabel="add attribute" itemValue="" />
                                            <f:selectItems   value="#{tranServiceBeanWizerd.aT}" />
                                        </p:selectOneMenu>
                                    </f:facet>  
                                </p:column>  
                                <p:column>  
                                    <f:facet name="header">  
                                        <h:outputText value="value" />  
                                    </f:facet>  
                                    <h:outputText value="#{tsa.value}"  />  
                                    <f:facet name="footer">  
                                        <p:inputText id="value"  label="value"  
                                                     value="#{tranServiceBeanWizerd.atvalue}" />  
                                        <p:commandButton value="add" id="ajax" >
                                            <f:ajax execute="value att"   render="newatt :main:growl"  
                                                    listener="#{tranServiceBeanWizerd.addatttolist()}" />


                                        </p:commandButton>

                                    </f:facet>  

                                </p:column>  
                            </p:dataTable> 


                        </h:panelGrid>  
                    </p:panel>  
                </p:tab>  
                <p:tab id="tsrw" title="Transportation Service Route AWAY" >  
                    <p:panel>
                        <p:toolbar styleClass="ui-panel-titlebar ui-widget-header">
                            <p:toolbarGroup align="left">                     
                                <p:commandButton  update="t1lat,t1lng,t2lat,t2lng,waypoint,growl"  icon="ui-icon-disk" oncomplete="calcRoute()"  value="Draw" action="#{tranServiceBeanWizerd.save}" />
                                <p:commandButton update="t1lat,t1lng,t2lat,t2lng,waypoint,terminals,points" value="clear" action="#{tranServiceBeanWizerd.clearall}" onclick="clearall()"  icon="ui-icon-trash" />
                            </p:toolbarGroup>
                        </p:toolbar>
                       
                                             
                        <p:outputPanel id="directionsPanel" styleClass="directionsPanel" rendered="false"  style="width:600px" layout="block"/> 
                        <p:panelGrid>  
                            <p:row>
                                <p:column>
                                    <p:gmap center="30.0522867441376,31.4069294929504" zoom="10" type="ROADMAP" 
                                            style="width:600px;height:400px"
                                            model="#{tranServiceBeanWizerd.simpleModel}"
                                            onPointClick="handlePointClick(event);"
                                            widgetVar="cliMap" fitBounds="true"
                                            id="map">
                                        <p:ajax event="overlaySelect"  oncomplete="afterrequest()" onstart="berforerequest()" update="map,terminals,points,growl" listener="#{tranServiceBeanWizerd.onMarkerSelect}"  />
                                    </p:gmap>
                                </p:column>
                                <p:column>
                                    <p:panelGrid columns="1" >
                                        <p:row>
                                            <p:dataTable id="terminals" var="point" value="#{tranServiceBeanWizerd.terminalMarkers}" liveResize="true" >
                                                <f:facet name="header">
                                                    Terminal points
                                                </f:facet>
                                                <p:column headerText="latlng">
                                                   <p:commandButton oncomplete="afterrequest()" onstart="berforerequest()"  value="Show" actionListener="#{tranServiceBeanWizerd.showmarker(point.latlng)}" update=":main:map"  />
                                                </p:column>

                                                <p:column headerText="name">
                                                    <h:outputText value="#{point.title}" />
                                                </p:column>
                                                
                                            </p:dataTable>
                                        </p:row>
                                        <p:row>
                                            <p:dataTable id="points"  var="point" value="#{tranServiceBeanWizerd.pointsMarkers}" draggableRows="true"  >
                                                <p:ajax event="rowReorder"  update=":main:map" />
                                                <f:facet name="header">
                                                    points
                                                </f:facet>
                                                <p:column headerText="latlng">
                                                    <p:commandButton value="show" oncomplete="afterrequest()" onstart="berforerequest()" actionListener="#{tranServiceBeanWizerd.showmarker(point.latlng)}"  update=":main:map"  />
                                                   
                                                </p:column>

                                                <p:column headerText="name">
                                                    <h:outputText value="#{point.title}" />
                                                </p:column>
                                               
                                            </p:dataTable>
                                        </p:row>
                                    </p:panelGrid>
                                </p:column>
                            </p:row>
                        </p:panelGrid>  
                    </p:panel>
                </p:tab> 

                
                
                
                
                
                
                
                
                
                
                
                

                <p:tab id="tsrh" title="Transportation Service Route HOME">  
                     <p:panel>
                        <p:toolbar styleClass="ui-panel-titlebar ui-widget-header">
                            <p:toolbarGroup align="left">                     
                                <p:commandButton  update="t1lat,t1lng,t2lat,t2lng,waypointh,growl"  icon="ui-icon-disk" oncomplete="calcRouteh()"  value="Draw" action="#{tranServiceBeanWizerd.save}" />
                                <p:commandButton update="t1lat,t1lng,t2lat,t2lng,waypointh,pointsh" value="clear" action="#{tranServiceBeanWizerd.clearallForHome}" onclick="clearall()"  icon="ui-icon-trash" />
                            </p:toolbarGroup>
                        </p:toolbar>
                                                               
                        <p:panelGrid>  
                            <p:row>
                                <p:column>
                                    <p:gmap center="30.0522867441376,31.4069294929504" zoom="10" type="ROADMAP" 
                                            style="width:600px;height:400px"
                                            model="#{tranServiceBeanWizerd.simpleModel}"
                                            onPointClick="handlePointClick(event);"
                                            widgetVar="cliMaph" fitBounds="true"
                                            id="maph">
                                        <p:ajax event="overlaySelect"  oncomplete="afterrequesth()" onstart="berforerequesth()" onsuccess="#{tranServiceBeanWizerd.test()}" update="maph,pointsh,growl" listener="#{tranServiceBeanWizerd.onMarkerSelect}"  />
                                    </p:gmap>
                                </p:column>
                                <p:column>
                                    <p:panelGrid columns="1" >
                                        <p:row>
                                            <p:dataTable id="terminalsh" var="point" value="#{tranServiceBeanWizerd.terminalMarkers}" liveResize="true" >
                                                <f:facet name="header">
                                                    Terminal points
                                                </f:facet>
                                                <p:column headerText="latlng">
                                                   <p:commandButton oncomplete="afterrequesth()" onstart="berforerequesth()"  value="Show" actionListener="#{tranServiceBeanWizerd.showmarker(point.latlng)}" update=":main:maph"  />
                                                </p:column>

                                                <p:column headerText="name">
                                                    <h:outputText value="#{point.title}" />
                                                </p:column>
                                                
                                            </p:dataTable>
                                        </p:row>
                                        <p:row>
                                            <p:dataTable id="pointsh" var="point" value="#{tranServiceBeanWizerd.hpointsMarkers}" draggableRows="true"  >
                                                <p:ajax event="rowReorder"  update=":main:maph" />
                                                <f:facet name="header">
                                                    points
                                                </f:facet>
                                                <p:column headerText="latlng">
                                                    <p:commandButton value="show" oncomplete="afterrequesth()" onstart="berforerequesth()" actionListener="#{tranServiceBeanWizerd.showmarker(point.latlng)}"  update=":main:maph"  />
                                                   
                                                </p:column>

                                                <p:column headerText="name">
                                                    <h:outputText value="#{point.title}" />
                                                </p:column>
                                               
                                            </p:dataTable>
                                        </p:row>
                                    </p:panelGrid>
                                </p:column>
                            </p:row>
                        </p:panelGrid>  
                    </p:panel>
                </p:tab>  
                
                
                
                
                
                
                
                
                
                <p:tab id="confirm" title="Confirmation">  
                    <p:panel header="Confirmation">  
                        <h:panelGrid id="confirmation" > 
                            <p:row>
                                <p:column>
                            <h:outputText value="Transportation name: " /> 
                            </p:column>
                            <p:column>
                            <h:outputText styleClass="outputLabel"  
                                          value="#{tranServiceBeanWizerd.tranService.name}" />  
                             </p:column>
                            </p:row>
                            <p:row>
                                <p:column>
                            <h:outputText value="Transportation Service: " />  
                            </p:column>
                                <p:column>
                            <h:outputText styleClass="outputLabel"  
                                          value="#{tranServiceBeanWizerd.tranService.tranServiceType.name}" /> 
                            </p:column>
                            </p:row>
                            <p:row>
                                <p:column>
                            <h:outputText value="Transportation Service Attribute: " />  
                            </p:column>
                                 </p:row>
                            <p:row>
                            <ui:repeat value="#{tranServiceBeanWizerd.tranServiceAttributesDataModel}" var="item" varStatus="loop">
                                 <h:outputText value="#{item.tranServiceTypeAttributeType.attributeType.name}" /> :  <h:outputText value="#{item.value}" /> <br/> 
                            </ui:repeat>
                            </p:row>
                           
                            <p:row>
                                <p:column>
                            <h:outputText value="Terminal Home: " />  
                            </p:column>
                                <p:column>
                            <h:outputText styleClass="outputLabel"  
                                          value="#{tranServiceBeanWizerd.t1.point.name}" /> 
                                </p:column>
                            </p:row>
                            <p:row>
                                <p:column>
                            <h:outputText value="Terminal Away: " /> 
                                </p:column>
                                <p:column>
                            <h:outputText styleClass="outputLabel"  
                                          value="#{tranServiceBeanWizerd.t2.point.name}" /> 
                                </p:column>
                            </p:row>
                            <p:row>
                                <p:column>
                            <h:outputText value="route" />  
                            </p:column>
                                 </p:row>
                            <p:row>
                                <p:dataTable id="cars" var="car" value="#{tranServiceBeanWizerd.tsrs}">                    
                                    <p:column sortBy="#{car.point.name}" >
                                        <f:facet name="header">
                                            <h:outputText value="away order" />
                                        </f:facet>
                                        <h:outputText value="#{car.point.name}" />
                                    </p:column>
                                    <p:column sortBy="#{car.awayOrder}" >
                                        <f:facet name="header">
                                            <h:outputText value="away order" />
                                        </f:facet>
                                        <h:outputText value="#{car.awayOrder}" />
                                    </p:column>
                                    <p:column sortBy="#{car.homeOrder}" >
                                        <f:facet name="header">
                                            <h:outputText value="home order" />
                                        </f:facet>
                                        <h:outputText value="#{car.homeOrder}" />
                                    </p:column>
                                </p:dataTable>
                            </p:row>
                            
                        </h:panelGrid>  
                        <p:commandButton update="growl" value="Submit"    
                                         actionListener="#{tranServiceBeanWizerd.add}"/>  
                    </p:panel>  
                </p:tab>  
            </p:wizard>  
        </h:form> 
    </h:body> 
</html>